<template>
    <div class="layout">
        <router-view name="login">
        </router-view>
        <Row type="flex" v-show="this.$route.meta.show">
            <Col span="3" class="layout-menu-left">
                <router-view name="second">
                </router-view>
            </Col>
            <Col span="21" style="overflow:auto">
                <div class="layout-header">
                    <div class="layout-breadcrumb">
                        <a>
                            <router-link to="/项目列表">首页</router-link>
                        </a> {{bread}}
                    </div>
                    <Button type="primary"  @click="logout" style="float:right;margin-top:15px;margin-right:20px;margin-left:20px;">退出</Button>
                    <span style="float:right;margin-top:15px;"> {{user}}        </span>

                </div>
                <div class="layout-content">
                    <div class="layout-content-main">
                        <router-view>
                        </router-view>
                    </div>
                </div>
            </Col>
        </Row>
    </div>
</template>
<script>
export default {
    data() {
        return {
            bread: '',
            user: ''
        }

    },
    methods: {
        openView(name) {
            this.$router.push(name)
            console.log(name);
            this.bread = "/" + name;
        },
        logout() {
            this.$store.dispatch('logout').then(() => {
                localStorage.removeItem("islogin");
                this.$router.replace('/login')

            })
        },
    },
    mounted() {
        var self = this
        $.ajaxSetup({
            statusCode: {
                1001: function() {
                    self.logout()
                },
            }
        })
    },
    created() {
        if(!localStorage.getItem("islogin")){
            this.$router.replace('/login')
        }
    },
    updated() {
        console.log(localStorage.islogin)
        this.user = localStorage.islogin
    }
}
</script>
<style>
@import 'style/style.css';

/*引入公共样式*/
</style>
